package com.fallsvc.re.javasesets.bgeneric;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Util {
    //静态的泛型方法 需要在static后用<>声明泛型类型参数
    public static <E> void swap(E[] array, int i, int j) {
        E t = array[i];
        array[i] = array[j];
        array[j] = t;
    }

    public static void main(String[] args) {
        Integer[] arr = {1,2};
        Util.swap(arr,0,1);
        System.out.println(Arrays.toString(arr));

        String str = "asdffghj";
        List<Integer> list= new ArrayList<>();
        list.add(10);
        list.add(20);
        list.add(30);
        Integer[] arr1 =list.toArray(new Integer[0]);
        System.out.println(Arrays.toString(arr1));
        System.out.println(list);
    }
}